<template>
	<view class="container">
		<u-popup v-model="IsShowPage" mode="center" length="85%" height="" closeable border-radius="20"  @close="close">
			<view style="padding: 20rpx;height: 100%;padding-top: 20rpx;padding-left: 20rpx;padding-right: 20rpx;">
				<view class="text-center fontWeight textColor text30" style="margin-bottom: 20rpx;">
					未提交名单
				</view>
				<view v-if="detailListData.length" class="flex Jbetween " v-for="(item,index) in detailListData" :key="index" style="margin-bottom: 10rpx;border-bottom: 1px solid #f5f5f5;padding-bottom: 15rpx;">
					<view  style="display:flex;flex: 5;display: flex;align-items: center;">
						<text  style="font-weight: bold;class=""">
							 {{item.key=='自然人'?'姓名':'单位'}}: 
						</text > 
						<text style="flex: 6;" class="name-content overflow ">{{item.name?item.name:item.unit_name}}</text>
					</view>
					<view class="" style="display: flex;justify-content: space-between;flex: 5;align-items: center;">
						<image style="width: 40rpx ;height: 40rpx;" src="../static/icon_message.png" mode="" @click="makeChange(item,1)"></image>
						<image  style="width: 50rpx ;height: 50rpx;" src="../static/icon_phone.png" mode="" @click="makeChange(item,2)"></image>
						<image  style="width: 50rpx ;height: 60rpx;" src="../static/icon_sms.png" mode=""  @click="makeChange(item,3)"></image>
					</view>
				</view>
				<view v-if="!detailListData.length"  class=" fontWeight text-center" style="color: #999999;">暂无未提交名单</view>
			</view>
		</u-popup>
		
	</view>
</template>

<script>
	
	export default {
		name: 'popup',
		props: {
			dataPopup: {
				type: Object,
				default: () => {}
			}
			
		},
		data() {
			return {
				IsShowPage:false,
				detailListData:[],//弹窗未提交人员列表数据
				liaison:'',//联络人姓名
				selected:null,//选择的是合同统计还是记账统计  用来区分接口
				isClose:false,//是否关闭弹窗
				user_type:null//自然人还是法人 还是联络人
			}
		},
		// created() {
		// 	console.log('获取父组件传递过来的获取父组件传递过来的获取父组件传递过来的获取父组件传递过来的',this.isShowPopup)
		// },
		watch: {
			dataPopup: {
				immediate: true,
				handler(nVal, oVal) {
					console.log('获取dataPopupdataPopupdataPopupdataPopupdataPopupdataPopupdataPopup',nVal)
					if (nVal) {
						// if(nVal.liaison && nVal.item){
						// 	this.liaison=nVal.liaison
						// 	this.user_type=nVal.item.key
						// 	this.selected=nVal.selected
						// }
						// if(this.selected==="记账"){
						// 	this.detailListData=[]
						// 	this.IsShowPage=nVal.isShowPopup //打开弹窗
						// }else {
						// 	this.IsShowPage=nVal.isShowPopup //打开弹窗
						// }
						// this.getContractDetails()
						// let data = JSON.parse(JSON.stringify(nVal.imgList.list))
						// this.activityOne = nVal.imgList.list[0]
						// data.splice(0, 1)
						// this.activity = data
						// this.isShow = nVal.isShow.val
					}
				}
			}
		},
		created() {
			let userInfo = uni.getStorageSync('userInfo');
			this.user_type=userInfo.user_type
			console.log('最终子组件获取的缓存内容',this.user_type)
		},
		methods:{
			close:function(){
				this.isClose=true
				this.$emit('close',this.isClose)
			},
			/* 短信 。电话。。发送信息点击事件 */
			makeChange:function(item,type){
				console.log('item,',item,type)
				let obj={
					item:item,
					type:type
				}
				this.$emit('makeChange',obj)
			},
			
			// // 未提交人员详情
			getContractDetails:function(){
				console.log('获取最终传递的参数',this.user_type,this.liaison,this.selected)
				var url=""
				var that=this
				
				if(this.selected==="合同"){
					uni.request({
						method: 'POST',
						url: 'https://jizhang.xqyu.cn/index.php/api/index/get_contract_details',
						dataType: 'json',
						header: {
							'content-type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_type: that.user_type,
							liaison:that.liaison
						},
						success: function (res) {
							that.$.hideLoading()// 数据加载完成，隐藏弹窗
							if (res.data.code == 1) {
								
								if(that.user_type=='自然人'){//以此判断自然人于法人显示姓名于单位
									res.data.data.forEach(item=>{
										item.key='自然人'
									})
								}else {
									res.data.data.forEach(item=>{
										item.key='法人'
									})
								}
								that.detailListData=res.data.data    
								console.log('成功that.detailListDatathat.detailListDatathat.detailListDatathat.detailListData',that.detailListData)
							}else{
								that.detailListData=[]
								 console.log('失败that.detailListDatathat.detailListDatathat.detailListDatathat.detailListData',that.detailListData)
							}
							 
						}
					})
				}else{
					console.log('开始调用记账未提交人员详情了',)
					uni.request({
						method: 'POST',
						url: 'https://jizhang.xqyu.cn/index.php/api/index/wei_list',
						dataType: 'json',
						header: {
							'content-type': 'application/x-www-form-urlencoded'
						},
						data: {
							type: that.user_type,
							name:that.liaison
						},
						success: function (res) {
							that.$.hideLoading()// 数据加载完成，隐藏弹窗
							if (res.data.code == 1) {
								
								// if(that.user_type=='自然人'){//以此判断自然人于法人显示姓名于单位
								// 	res.data.data.forEach(item=>{
								// 		item.key='自然人'
								// 	})
								// }else {
								// 	res.data.data.forEach(item=>{
								// 		item.key='法人'
								// 	})
								// }
								// that.detailListData=res.data.data    
								console.log('成功获取记账列表详情数据',res.data)
							}else{
								that.detailListData=[]
								 console.log('失败获取记账列表详情数据a',that.detailListData)
							}
							 
						}
					})
				}
			}
		}
	}
</script>

<style>
</style>
